package com.aitemv.utils;

public class PageBean {
	private int startPage; // start表示当前页开始的记录数,start=每页行数*(当前页数-1)
	private int currentPage;// 当前是第几页
	private int pageSize = 10;// 每页显示多少条，默认是10条
	private int totalPages;// 一共有多少页
	private int totalRows;

	public PageBean(int _currentPage, int _totalRows) {
		totalRows = _totalRows;
		totalPages = totalRows / pageSize;
		if (totalRows % pageSize > 0)
			totalPages++;
		if (_currentPage <= 0 || _currentPage > totalPages) {
			if (totalRows > 0)
				currentPage = 1;
			else
				currentPage = 0;
			startPage = 0;
		} else {
			currentPage = _currentPage;
			startPage = (currentPage - 1) * pageSize;
		}

	}

	public PageBean(int _totalRows,int _startPage, int _pageSize) {
		totalRows = _totalRows;
		startPage = _startPage;
		pageSize = _pageSize;
		totalPages = totalRows / pageSize;
		if (totalRows % pageSize > 0)
			totalPages++;
	}
	
	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getStartPage() {
		return startPage;
	}

	public void setStartPage(int startPage) {
		this.startPage = startPage;
	}

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public int getTotalRows() {
		return totalRows;
	}

	public void setTotalRows(int totalRows) {
		this.totalRows = totalRows;
	}
}
